package com.example.basic.web.controller.pharmStock;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.basic.core.result.Result;
import com.example.basic.core.result.ResultGenerator;
import com.example.basic.custom.Log;
import com.example.basic.web.response.PharmStockResponse;
import com.example.basic.web.service.pharmStock.PharmStockService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@Api(value  = "库存管理", tags = {"库存管理"})
@RestController
@RequestMapping("/api/v1/byg/pharmStock")
public class PharmStockController {

    @Resource
    private PharmStockService pharmStockService;

    @Log(title = "库存管理", description = "列表")
    @ApiOperation(value = "列表", notes = "列表")
    @PostMapping("/queryList")
    public Result<IPage<PharmStockResponse>> queryList(
            @ApiParam(name = "searchParam", value = "模糊搜索(遗体名称，拼音码，五笔码)") @RequestParam(required = false) String searchParam,
            @ApiParam(name = "sex", value = "性别 0-全部") @RequestParam(defaultValue = "0") String sex,
            @ApiParam(name = "pharmCode", value = "库房编码 0-全部") @RequestParam(defaultValue = "0") String pharmCode,
            @ApiParam(name = "zoneCode", value = "分区编码 0-全部") @RequestParam(defaultValue = "0") String zoneCode,
            @ApiParam(name = "depotCode", value = "库位编码 0-全部") @RequestParam(defaultValue = "0") String depotCode,
            @ApiParam(name = "status", value = "状态 0-全部 1-空闲，2-占用") @RequestParam(defaultValue = "0") String status,
            @ApiParam(name = "page", value = "页数，list分页的第几页") @RequestParam(defaultValue = "0") Integer page,
            @ApiParam(name = "size", value = "条数，list分页的每页条数") @RequestParam(defaultValue = "0") Integer size) {
        Page<PharmStockResponse> queryPage = new Page<>(page,size);
        return ResultGenerator.genSuccessResult(pharmStockService.queryList(queryPage,searchParam, sex,pharmCode,zoneCode,depotCode,status));
    }

    @Log(title = "库存管理", description = "待出库列表")
    @ApiOperation(value = "待出库列表", notes = "待出库列表")
    @PostMapping("/waitOutList")
    public Result<IPage<PharmStockResponse>> waitOutList(
            @ApiParam(name = "searchParam", value = "模糊搜索(遗体名称，拼音码，五笔码)") @RequestParam(required = false) String searchParam,
            @ApiParam(name = "sex", value = "性别 0-全部") @RequestParam(defaultValue = "0") String sex,
            @ApiParam(name = "beginTime", value = "开始日期 yyyy-mm-dd") @RequestParam(required = false) String beginTime,
            @ApiParam(name = "endTime", value = "结束日期 yyyy-mm-dd") @RequestParam(required = false) String endTime,
            @ApiParam(name = "page", value = "页数，list分页的第几页") @RequestParam(defaultValue = "0") Integer page,
            @ApiParam(name = "size", value = "条数，list分页的每页条数") @RequestParam(defaultValue = "0") Integer size) {
        Page<PharmStockResponse> queryPage = new Page<>(page,size);
        return ResultGenerator.genSuccessResult(pharmStockService.waitOutList(queryPage,searchParam,sex,beginTime,endTime));
    }
}
